package serviceimpl;

import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.net.UnknownHostException;
import java.util.Enumeration;

import org.apache.http.message.BasicHeader;

import service.ws.CommonWSHandler;
import service.ws.WSHandler;

public class IP {
	public static void main(String[] args) throws UnknownHostException {
		 try {
			 
			WSHandler wsHandler = new CommonWSHandler("http://dydywang.com/3218.html");
			wsHandler.addHeader(new BasicHeader("User-Agent","Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36"));
			wsHandler.addHeader(new BasicHeader("Accept-Language","zh-CN,zh;q=0.8"));
			wsHandler.addHeader(new BasicHeader("Accept","text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"));
			
			wsHandler.get();
			Enumeration<NetworkInterface> networks = NetworkInterface.getNetworkInterfaces();
			Enumeration<InetAddress> addrs = networks.nextElement().getInetAddresses();
			 while (addrs.hasMoreElements())
             {
				 InetAddress ip = addrs.nextElement();
                 if (ip != null
                         && ip instanceof Inet4Address
                         && ip.isSiteLocalAddress()
                         )
                 {
                     System.out.println(ip.getHostAddress());
                 }
             }
		} catch (SocketException e) {
			e.printStackTrace();
		}
	}
}
